<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 多React -->
    <script type="text/javascript" src="../js/react.development.js" ></script>
    <!-- 多ReactDOM -->
    <script type="text/javascript" src="../js/react-dom.development.js" ></script>
    <script type="text/javascript" src="../js/babel.min.js" ></script>
    <!-- 引入prop-types，用于限制组件标签的属性,引入后会多1个对象PropTypes -->
    <script type="text/javascript" src="https://cdn.bootcss.com/prop-types/15.6.1/prop-types.js" ></script>
    
    <style>
        .title{
            background-color: orange;
            width:500px;
        }
    </style>
</head>
<body>
    <div id="test1"></div>
    <div id="test2"></div>
    <div id="test3"></div>
    <script type="text/babel">

        //函数式组件用参数接受传递
        // 函数式组件只能用props接受传递的参数
        function MyComponent(props){
            const {isHot} = this.props
            return (
                    <div>
                        <h1 className="title">
                            <span style={{color:'white'}}>zzzzzzz{isHot?'热':'凉爽'}</span>
                        </h1>
                    </div>
                )
        }
        MyComponent.propTypes = {
                isHot:PropTypes.bool.isRequired,
                speak:PropTypes.func
        }
        MyComponent.defaultPops = {
            isHot:true
        }

        ReactDOM.render(<MyComponent isHot={false} />,document.getElementById('test1'))
        ReactDOM.render(<MyComponent isHot={false} />,document.getElementById('test2'))
        ReactDOM.render(<MyComponent isHot={false} />,document.getElementById('test3'))
        
        const p = {isHot:true}
        ReactDOM.render(<MyComponent {...p} />,document.getElementById('test3'))

        function speak(){

        }

    </script>
</body>
</html>